package domain.DAO;

import javax.servlet.ServletContext;

import org.springframework.web.context.WebApplicationContext;
import org.springframework.web.context.support.WebApplicationContextUtils;

import domain.interfaces.IDAOAddress;
import domain.interfaces.IDAOContact;
import domain.interfaces.IDAOContactGroup;
import domain.interfaces.IDAOEntreprise;
import domain.interfaces.IDAOPhoneNumber;

public class DAOFactory {

	public DAOFactory() {

	}

	public static IDAOAddress getDAOAddress(ServletContext ctx) {
		WebApplicationContext context = WebApplicationContextUtils
				.getRequiredWebApplicationContext(ctx);
		return context.getBean(IDAOAddress.class);
	}

	public static IDAOContactGroup getDAOContactGroup(ServletContext ctx) {
		WebApplicationContext context = WebApplicationContextUtils
				.getRequiredWebApplicationContext(ctx);
		return context.getBean(IDAOContactGroup.class);
	}

	public static IDAOContact getDAOContact(ServletContext ctx) {
		WebApplicationContext context = WebApplicationContextUtils
				.getRequiredWebApplicationContext(ctx);
		return context.getBean(IDAOContact.class);
	}
	
	public static IDAOEntreprise getDAOEntreprise(ServletContext ctx)
	{
		WebApplicationContext context = WebApplicationContextUtils
				.getRequiredWebApplicationContext(ctx);
		return context.getBean(IDAOEntreprise.class);
	}

	public IDAOPhoneNumber getDAOPhoneNumber() {
		return new DAOPhoneNumber();
	}

}
